#pragma once


// CProcessTreeCtrl

class PROCESSINFO
{
public:
	CString *lpstrProcessName;
	DWORD uProcessID;
	DWORD uParentProcessID;
	BOOL bIsProcessed;

	PROCESSINFO()
	{
		lpstrProcessName = new CString;
		uProcessID = 0;
		uParentProcessID = 0;
		bIsProcessed = FALSE;
	}

	~PROCESSINFO()
	{
		delete lpstrProcessName;
	}
};

class CProcessTreeCtrl : public CTreeCtrl
{
	DECLARE_DYNAMIC(CProcessTreeCtrl)

public:
	CProcessTreeCtrl();
	virtual ~CProcessTreeCtrl();

private:
	VOID AddProcess(PROCESSINFO *pInfo, PROCESSINFO *pParentInfo);
	VOID AddThread(DWORD dwThreadID, HTREEITEM hParent);
	HTREEITEM LookForProcessTreeItem(HTREEITEM hNode, PROCESSINFO *pInfo);
	VOID CreateProcessTree(CList<PROCESSINFO*, PROCESSINFO*> *lstProcessInfo, INT nParentProcessID);
	CString GetModulePath(DWORD uProcessID);
	VOID GetProcessTree(HTREEITEM hTreeItem, CList<DWORD, DWORD> *pLst);
public:
	VOID Refresh(void);

protected:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult);
	DECLARE_MESSAGE_MAP()
public:
	DWORD GetSelectedThreadID(void);
	DWORD GetSelectedProcessID(void);
	VOID GetSelectedProcessTree(CList<DWORD, DWORD> *pLst);
	VOID Clear(void);
};


